package major;
import test.Common;
import java.io.*;

class Student extends Common {

    public Student(int id, int age, String name, String gender) {
        super();
        this.id = id;
        this.age = age;
        this.name = name;
        this.gender = gender;
    }

}

class Teacher extends Common {

    public Teacher(int id, int age, String name, String gender) {
        super();
        this.id = id;
        this.age = age;
        this.name = name;
        this.gender = gender;

    }
}

class Course extends Common {
    //    与学生类和老师类不同的地方
    String place;
    String time;

    public Course(int id, String name, String place, String time) {
        this.id = id;
        this.name = name;
        this.place = place;
        this.time = time;
    }

    @Override
    public String toString() {
        return "Course{" +
                "place='" + place + '\'' +
                ", time='" + time + '\'' +
                '}';
    }

    public String getPlace() {
        return place;
    }

    public String getTime() {
        return time;
    }
}

public class principal<len> {
    public static void main(String[] args) throws IOException {



        Student student1 = new Student(101, 19, "小明", "男");
        Student student2 = new Student(102, 20, "小红", "女");
        Teacher teacher1 = new Teacher(001, 38, "王老师", "女");
        Teacher teacher2 = new Teacher(002, 35, "张老师", "男");
        Course course1 = new Course(1101, "Java", "综合教学楼103", "星期四上午十点");
        Course course2 = new Course(1102, "Python", "综合教学楼203", "星期二早上八点");



        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream("F:\\JAVA练习\\课表.txt"));

        outputStreamWriter.write("编号：" + "" + student1.id + "/" + "学生:" + student1.getName() + "/" + "年龄：" + student1.age + "/" + "选择的科目是：" + course2.getName() +"/"+ "授课老师："
                + teacher1.name +"/"+ "\n" +

                "上课地点是:" + course2.getPlace() + "/"
                + "上课时间是:" + course2.getTime()+ "/"
                + "\n" + "\n" +

                "编号：" + "" + student2.id + "/" + "学生:" + student2.getName() + "/" + "年龄：" + student2.age + "/" + "选择的科目是：" + course1.getName() +"/"+ "授课老师："
                + teacher2.name +"/"+ "\n" +

                "上课地点是:" + course1.getPlace() + "/"
                + "上课时间是:" + course1.getTime()+ "/"

//                "编号：" + "  " + student2.id + "  " + "学生:" + student2.getName() + "  " + "年龄：" + student2.age + "  " + "选择的科目是：" + course1.getName() + "授课老师：" + "  "
//                + teacher2.name + "\n" +
//
//                "上课地点是:" + "  " + course1.getPlace() + "  "
//                + "上课时间是:" + "  " + course1.getTime()
        );

        outputStreamWriter.close();
        InputStreamReader inputStreamReadernew = new InputStreamReader(new FileInputStream("F:\\JAVA练习\\课表.txt"));
        char[] chars = new char[1024];
        int len;
        while ((len = inputStreamReadernew.read(chars)) != -1) {
            System.out.println(new String(chars, 0, len));
        }
        inputStreamReadernew.close();
    }

}